USE [WorldIndex]
GO
/****** Object:  Table [dbo].[MdgFootnotes]    Script Date: 09/09/2009 12:31:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MdgFootnotes](
	[Code] [int] NOT NULL,
	[Description] [text] NULL,
 CONSTRAINT [PK_MdgFootnotes] PRIMARY KEY CLUSTERED 
(
	[Code] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[MdgCountry]    Script Date: 09/09/2009 12:31:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MdgCountry](
	[Code] [int] NOT NULL,
	[Name] [nvarchar](500) NULL,
 CONSTRAINT [PK_MdgCountry] PRIMARY KEY CLUSTERED 
(
	[Code] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[MdgTypes]    Script Date: 09/09/2009 12:31:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MdgTypes](
	[Type] [nvarchar](5) NOT NULL,
	[Name] [nvarchar](255) NULL,
	[Description] [text] NULL,
 CONSTRAINT [PK_MdgTypes] PRIMARY KEY CLUSTERED 
(
	[Type] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[MdgSeriesDefinition]    Script Date: 09/09/2009 12:31:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MdgSeriesDefinition](
	[SeriesCode] [int] NOT NULL,
	[IsMDG] [bit] NOT NULL,
	[SeriesDescription] [text] NOT NULL,
 CONSTRAINT [PK_MdgSeriesDefinition] PRIMARY KEY CLUSTERED 
(
	[SeriesCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[MdgSeriesData]    Script Date: 09/09/2009 12:31:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[MdgSeriesData](
	[Id] [int] NOT NULL,
	[CountryCode] [int] NOT NULL,
	[SeriesCode] [int] NOT NULL,
	[Year] [varchar](4) NOT NULL,
	[Value] [decimal](18, 0) NULL,
	[Type] [nvarchar](5) NULL,
 CONSTRAINT [PK_MdgSeriesData] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [DataIndex] ON [dbo].[MdgSeriesData] 
(
	[CountryCode] ASC,
	[SeriesCode] ASC,
	[Year] ASC,
	[Value] ASC,
	[Type] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[MdgSeriesDataFootnotes]    Script Date: 09/09/2009 12:31:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MdgSeriesDataFootnotes](
	[MdgSeriesDataId] [int] NOT NULL,
	[FootnodeCode] [int] NOT NULL,
 CONSTRAINT [PK_MdgSeriesDataFootnotes] PRIMARY KEY CLUSTERED 
(
	[FootnodeCode] ASC,
	[MdgSeriesDataId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  ForeignKey [FK_MdgSeriesData_MdgCountry]    Script Date: 09/09/2009 12:31:43 ******/
ALTER TABLE [dbo].[MdgSeriesData]  WITH CHECK ADD  CONSTRAINT [FK_MdgSeriesData_MdgCountry] FOREIGN KEY([CountryCode])
REFERENCES [dbo].[MdgCountry] ([Code])
GO
ALTER TABLE [dbo].[MdgSeriesData] CHECK CONSTRAINT [FK_MdgSeriesData_MdgCountry]
GO
/****** Object:  ForeignKey [FK_MdgSeriesData_MdgSeriesDefinition]    Script Date: 09/09/2009 12:31:43 ******/
ALTER TABLE [dbo].[MdgSeriesData]  WITH CHECK ADD  CONSTRAINT [FK_MdgSeriesData_MdgSeriesDefinition] FOREIGN KEY([SeriesCode])
REFERENCES [dbo].[MdgSeriesDefinition] ([SeriesCode])
GO
ALTER TABLE [dbo].[MdgSeriesData] CHECK CONSTRAINT [FK_MdgSeriesData_MdgSeriesDefinition]
GO
/****** Object:  ForeignKey [FK_MdgSeriesData_MdgTypes]    Script Date: 09/09/2009 12:31:43 ******/
ALTER TABLE [dbo].[MdgSeriesData]  WITH CHECK ADD  CONSTRAINT [FK_MdgSeriesData_MdgTypes] FOREIGN KEY([Type])
REFERENCES [dbo].[MdgTypes] ([Type])
GO
ALTER TABLE [dbo].[MdgSeriesData] CHECK CONSTRAINT [FK_MdgSeriesData_MdgTypes]
GO
/****** Object:  ForeignKey [FK_MdgSeriesDataFootnotes_MdgFootnotes]    Script Date: 09/09/2009 12:31:43 ******/
ALTER TABLE [dbo].[MdgSeriesDataFootnotes]  WITH CHECK ADD  CONSTRAINT [FK_MdgSeriesDataFootnotes_MdgFootnotes] FOREIGN KEY([FootnodeCode])
REFERENCES [dbo].[MdgFootnotes] ([Code])
GO
ALTER TABLE [dbo].[MdgSeriesDataFootnotes] CHECK CONSTRAINT [FK_MdgSeriesDataFootnotes_MdgFootnotes]
GO
/****** Object:  ForeignKey [FK_MdgSeriesDataFootnotes_MdgSeriesData]    Script Date: 09/09/2009 12:31:43 ******/
ALTER TABLE [dbo].[MdgSeriesDataFootnotes]  WITH CHECK ADD  CONSTRAINT [FK_MdgSeriesDataFootnotes_MdgSeriesData] FOREIGN KEY([MdgSeriesDataId])
REFERENCES [dbo].[MdgSeriesData] ([Id])
GO
ALTER TABLE [dbo].[MdgSeriesDataFootnotes] CHECK CONSTRAINT [FK_MdgSeriesDataFootnotes_MdgSeriesData]
GO
